package com.securitytrace.client.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.apache.log4j.Logger;

import com.securitytrace.client.Manager;
import com.securitytrace.client.RFIDManagerFactory;
import com.securitytrace.client.ui.MainFrame;
import com.securitytrace.client.ui.MainFrameFactory;

public class MainFrameStopButtonListener implements ActionListener{

	private static final Logger logger = Logger.getLogger(MainFrameStopButtonListener.class);

	MainFrame mainFrame = MainFrameFactory.getMainFrame();

	@Override
	public void actionPerformed(ActionEvent e) {
		logger.debug("点击停止服务按钮");
		mainFrame.getStartButton().setEnabled(true);
		mainFrame.getStopButton().setEnabled(false);
		
		if(mainFrame.getSelectProductComboBox() != null){
			mainFrame.getSelectProductComboBox().setEnabled(true);
		}
		
		String frontText = mainFrame.getOptionTextArea().getText();
		mainFrame.getOptionTextArea().setText(frontText+"服务已经停止！\n");
		Manager manager = RFIDManagerFactory.getInstance();
		manager.stop();
	}

}
